package com.jm.product.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.google.common.collect.Lists;
/**
 * 商品规格Entity
 * @author sunshine
 * @version 2017-07-03
 */
@Entity
@Table(name = "es_specification")
@Cache(region = "com.jm.cache", usage = CacheConcurrencyStrategy.READ_WRITE)
public class Specification extends IdEntity<Integer> implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
    @Column(name="spec_name")
	private String specName;//规格名称
    @Column(name="spec_show_type")
	private String specShowType;//spec_show_type
    @Column(name="spec_type")
	private String specType;//类型
    @Column(name="spec_memo")
	private String specMemo;//规格备注
    @Column(name="spec_order")
	private Integer specOrder;//spec_order
    @Column(name="disabled")
	private String disabled;//disabled

    @OneToMany(mappedBy="specification",orphanRemoval=true,
    		cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<SpecValues> specValuesList = Lists.newArrayList();

    @OneToMany(mappedBy = "specification",orphanRemoval=true,
    		cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<TypeSpecMap> typeSpecMap = Lists.newArrayList() ;

	public Specification() {
		super();
	}
	
	/**
	*
	* get 规格名称
	*
	* return specName
	*/
	public String getSpecName() {
		return this.specName;
	}
	
	/**
	 * 
	 * set 规格名称
	 * 
	 * @param specName
	 */
	public void setSpecName(String specName) {
		this.specName = specName;
	}
	/**
	*
	* get spec_show_type
	*
	* return specShowType
	*/
	public String getSpecShowType() {
		return this.specShowType;
	}
	
	/**
	 * 
	 * set spec_show_type
	 * 
	 * @param specShowType
	 */
	public void setSpecShowType(String specShowType) {
		this.specShowType = specShowType;
	}
	/**
	*
	* get 类型
	*
	* return specType
	*/
	public String getSpecType() {
		return this.specType;
	}
	
	/**
	 * 
	 * set 类型
	 * 
	 * @param specType
	 */
	public void setSpecType(String specType) {
		this.specType = specType;
	}
	/**
	*
	* get 规格备注
	*
	* return specMemo
	*/
	public String getSpecMemo() {
		return this.specMemo;
	}
	
	/**
	 * 
	 * set 规格备注
	 * 
	 * @param specMemo
	 */
	public void setSpecMemo(String specMemo) {
		this.specMemo = specMemo;
	}
	/**
	*
	* get spec_order
	*
	* return specOrder
	*/
	public Integer getSpecOrder() {
		return this.specOrder;
	}
	
	/**
	 * 
	 * set spec_order
	 * 
	 * @param specOrder
	 */
	public void setSpecOrder(Integer specOrder) {
		this.specOrder = specOrder;
	}
	/**
	*
	* get disabled
	*
	* return disabled
	*/
	public String getDisabled() {
		return this.disabled;
	}
	
	/**
	 * 
	 * set disabled
	 * 
	 * @param disabled
	 */
	public void setDisabled(String disabled) {
		this.disabled = disabled;
	}

    public List<SpecValues> getSpecValuesList() {
        return specValuesList;
    }

    public void setSpecValuesList(List<SpecValues> specValuesList) {
        this.specValuesList = specValuesList;
    }
	
	public List<TypeSpecMap> getTypeSpecMap() {
		return typeSpecMap;
	}

	public void setTypeSpecMap(List<TypeSpecMap> typeSpecMap) {
		this.typeSpecMap = typeSpecMap;
	}

	@Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        result = prime * result + ((specName == null) ? 0 : specName.hashCode());
        result = prime * result + ((specShowType == null) ? 0 : specShowType.hashCode());
        result = prime * result + ((specType == null) ? 0 : specType.hashCode());
        result = prime * result + ((specMemo == null) ? 0 : specMemo.hashCode());
        result = prime * result + ((specOrder == null) ? 0 : specOrder.hashCode());
        result = prime * result + ((disabled == null) ? 0 : disabled.hashCode());
        return result;
    }
	
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Specification other = (Specification) obj;
        if (id == null) {
            if (other.id != null)
                return false;
        } else if (!id.equals(other.id))
            return false;
        if (specName == null) {
            if (other.specName != null)
                return false;
        } else if (!specName.equals(other.specName))
            return false;
        if (specShowType == null) {
            if (other.specShowType != null)
                return false;
        } else if (!specShowType.equals(other.specShowType))
            return false;
        if (specType == null) {
            if (other.specType != null)
                return false;
        } else if (!specType.equals(other.specType))
            return false;
        if (specMemo == null) {
            if (other.specMemo != null)
                return false;
        } else if (!specMemo.equals(other.specMemo))
            return false;
        if (specOrder == null) {
            if (other.specOrder != null)
                return false;
        } else if (!specOrder.equals(other.specOrder))
            return false;
        if (disabled == null) {
            if (other.disabled != null)
                return false;
        } else if (!disabled.equals(other.disabled))
            return false;
        return true;
    }
	
 	@Override
    public String toString() {
        return "Specification [id=" + id + ",specName=" + specName + ",specShowType=" + specShowType + ",specType=" + specType + ",specMemo=" + specMemo + ",specOrder=" + specOrder + ",disabled=" + disabled + "]";
    }
}


